<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 利用字面量创建对象 */
        var obj = {
            uname:'xiaoxue',
            age:18,
            sex:'boy',
            sayHi:function(){
                console.log('hi~')
            }
        }
        console.log(obj.uname);
        console.log(obj['sex']);
        obj.sayHi();


        var obj1 = new Object();
        obj.uname='xiaoxue';
        obj.age=16;
        obj.sayHi=function(){
            console.log();
        }


        /* 利用构造函数创建对象 */

       /*  function 构造函数名(){
            this.属性 = 值
            this.方法 = function(){

            }
        }
        new 构造函数名();
 */

        function Star(uname,age,sex){
            this.name = uname
            this.age = age
            this.sex = sex
            this.sing = function(){
                console.log('fish');
            }
        }
        var tb = new Star('xiaoxue',18,'boy')
        console.log(tb.name)
    </script>
</body>
</html>